/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * WeatherPanel.java
 *
 * Created on Feb 16, 2013, 7:26:49 PM
 */
package edu.ncsu.csc510.project.guilayer;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import net.miginfocom.swing.MigLayout;

/**
 *
 * @author svpendse1
 */
public class WeatherPanel extends javax.swing.JPanel {
   JLabel conditionsLabel, tempLabel;
   JLabel dewpointLabel, visibilityLabel;
   JLabel windLabel, skyLabel;
   JLabel delayLabel, trendLabel, changeLabel;
    /** Creates new form WeatherPanel */
    public WeatherPanel() {
        initComponents();
               
        this.setLayout(new MigLayout("fillx, insets", "[]10[]", "[]5[]"));
        this.add(conditionsLabel = new JLabel("Conditions: "), "left");
        this.add(tempLabel = new JLabel("Temperature: "), "left, wrap");
        this.add(dewpointLabel = new JLabel("Dewpoint: "), "left");
        this.add(visibilityLabel = new JLabel("Visibility: "), "left, wrap");
        this.add(windLabel = new JLabel("Wind: "), "left");
        this.add(delayLabel = new JLabel("Delay Index : "), "left, wrap");
        this.add(trendLabel = new JLabel("Trend : "), "left");
        this.add(changeLabel = new JLabel("Change : "), "left, wrap");
        this.add(skyLabel = new JLabel("Sky Conditions: "), "left, span 2 1, wrap");
        
        this.setBorder(BorderFactory.createTitledBorder("Weather"));  
        this.setVisible(false);
    }

    public void setVisibility(String visibility) {
        System.out.println("Visibility : " + visibility);
        visibilityLabel.setText("<html><b>Visibility : </b>" + visibility.trim().replaceAll("\t", "").replaceAll("\n", "") + "</html>");    
    }
    
    public void setWind(String wind) {
        System.out.println("Wind : " + wind);
        windLabel.setText("<html><b>Wind : </b>" + wind.trim().replaceAll("\t", "").replaceAll("\n", "") + "</html>");
    }
    
    public void setSky(String sky) {

        //!!TODO : Figure out a way to represent long descriptions of sky conditions without breaking the layout aesthetics.
        System.out.println("Sky Conditions : " + sky);
        sky = sky.substring(0, sky.indexOf("."));
        skyLabel.setText("<html><b>Sky Conditions : </b>" + sky.trim().replaceAll("\t", "").replaceAll("\n", "") + ". </html>");
    }
    
    public void setDelay(String delay) {
        System.out.println("Delays: " + delay);  
        delayLabel.setText("<html><b>Delays : </b>" + delay.trim().replaceAll("\t", "").replaceAll("\n", "") + "</html>");
    }

    public void setTrend(String trend) {
        System.out.println("Trend : " + trend);
        trendLabel.setText("<html><b>Trend : </b>" + trend.trim().replaceAll("\t", "").replaceAll("\n", "") + "</html>");
    }

    public void setChange(String change) {
        System.out.println("Change : " + change);
        changeLabel.setText("<html><b>Change : </b>" + change.trim().replaceAll("\t", "").replaceAll("\n", "") + "</html>");
    }
    
    public void setConditions(String conditions) {
        System.out.println("Conditions : " + conditions);
        conditionsLabel.setText("<html><b>Conditions : </b>" + conditions.trim().replaceAll("\t", "").replaceAll("\n", "") + "</html>");
    }

    public void setTemperature(String temp) {
        tempLabel.setText("<html><b>Temperature : </b>" + temp.trim().replaceAll("\t", "").replaceAll("\n", "") + "</html>");
    }

    public void setDewpoint(String dewpoint) {
        dewpointLabel.setText("<html><b>Dewpoint : </b>" + dewpoint.trim().replaceAll("\t", "").replaceAll("\n", "") + "</html>");
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
}
